<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>骡窝窝系统管理平台</title>
<#include "../common/header.ftl"/>

    <script type="text/javascript">
        $(function(){
            //模态框
            $('.showContent').click(function () {
                var id = $(this).data("tid");
                $.get("/daily/getContentById.do",{id:id},function (data) {
                    console.log(data);
                    $("#showContent .modal-body").html(data.dailyContent);
                });
                $('#showContent').modal('show');
            });
            $("#query").click(function(){
                $("#currentPage").val();
                $("#searchForm").submit();
            });
            //模态框

            $(".showBtn").click(function(){
                $('#editForm input').val("");
                var obj=$(this).data("json");
                console.log(obj);
                if(obj){
                    $('#editForm input[name="id"]').val(obj.id);
                    $('#editForm input[name="title"]').val(obj.title);
                    $('#editForm select[name="state"]').val(obj.state+"");
                    $('#coverUrl').attr('src',obj.coverUrl);
                    $('#editForm input[name="coverUrl"]').val(obj.coverUrl);

                }
                $('#showModal').modal('show')
            });

        });
    </script>
</head>

<body>
<div class="container">
<#include "../common/top.ftl"/>
    <div class="row">
        <div class="col-sm-3">
		<#assign currentMenu = "release" />
				<#include "../common/menu.ftl" />
        </div>
        <div class="col-sm-9">
            <div class="page-header">
                <h3>日报管理</h3>
            </div>
            <div class="row">
                <!-- 提交分页的表单 -->
                <form id="searchForm" class="form-inline" method="post" action="/daily/list.do">
                    <input type="hidden" name="currentPage" id="currentPage" value="1"/>
                    <div class="form-group">
                    </div>
                    <div class="form-group">
                        <label>关键字</label>
                        <input class="form-control" type="text" name="keyword" value="${(qo.keyword)!''}">
                    </div>
                    <div class="form-group">
                        <button id="query" type="button" class="btn btn-success"><i class="icon-search"></i> 查询</button>
                    </div>
                    <div class="form-group">
                        <button  type="button" class="btn btn-success showBtn"><i class="icon-search"></i> 添加</button>
                    </div>
                </form>
            </div>

            <table class="table">
                <thead>
                <tr>
                    <th>编号</th>
                    <th>标题</th>
                    <th>封面</th>
                    <th>创建时间</th>
                    <th>最后更新时间</th>
                    <th>点赞数</th>
                    <th>状态</th>
                    <th></th>
                </tr>
                </thead>
                <tbody>
                <#list pageInfo.list as vo>
                <tr>
                    <td>${vo_index+1}</td>
                    <td>${(vo.title!"")!}</td>
                    <td><img src='${(vo.coverUrl!"")!}' width="30px"/></td>
                    <td>${(vo.dailyCreateTime?string("yyyy-MM-dd HH:mm:ss"))!}</td>
                    <td>${(vo.lastUpdateTime?string("yyyy-MM-dd HH:mm:ss"))!}</td>
                    <td>${(vo.likes)!}</td>
                    <td>
                        <#if vo.state == 0>
                            普通
                        <#elseif vo.state == 1>
                            推荐
                        </#if>
                    </td>
                    <td>
                        <a href="javascript:" class="btn btn-info btn-xs showBtn" data-json='${vo.json}'>
                            <span class="glyphicon glyphicon-pencil"></span> 修改
                        </a>
                        <a href="javascript:" class="btn btn-info btn-xs showContent" data-tid="${vo.id}">
                            <span class="glyphicon glyphicon-pencil"></span> 查看内容
                        </a>
                    </td>
                    <td></td>
                </tr>
                </#list>
                </tbody>
            </table>
        <#include "../common/page.ftl"/>
        </div>
    </div>
</div>
</div>


<div class="modal fade" id="showModal" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">日报修改</h4>
            </div>
            <div class="modal-body">

                <form class="form-horizontal" action="/daily/saveOrUpdate.do" method="post" id="editForm" >
                    <input type="hidden"  name="id">
                    <div class="form-group" >
                        <label for="name" class="col-sm-4 control-label">标题：</label>
                        <div class="col-lg-7">
                            <input type="text" class="form-control"  name="title" >
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">封面：</label>
                        <div class="col-lg-7">
                            <img id="coverUrl"><!--用来显示图片,因为img不能提交所以用隐藏域提交-->
                            <input type="hidden" class="form-control"  name="coverUrl" ><!--表单提交-->
                            <input type="file" class="form-control"  name="file" ><!--上传文件-->
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="sn" class="col-sm-4 control-label">状态：</label>
                        <div class="col-lg-7">
                            <select class="c-select form-control" name="state" >
                                <option value="0">普通</option>
                                <option value="1">头条</option>
                            </select>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary submitBtn">保存</button>
            </div>
        </div>
    </div>
</div>
<div class="modal fade" id="showContent" tabindex="-1" role="dialog" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">查看内容</h4>
            </div>
            <div class="modal-body">

            </div>

        </div>
    </div>
</div>
<style>
    #showModal img{
        width:100%
    }
    #showModal  .modal-body{
        max-height: 600px;
        overflow-y: auto;
    }

</style>
<style>
    #showContent img{
        width:100%
    }
    #showContent  .modal-body{
        max-height: 600px;
        overflow-y: auto;
    }

</style>
</body>
</html>